package com.springboot.strategy.demo002;

public class StrategyFactory {
    public static IStrategy getStrategy(String strategyCode){
        try {
            StrategyEnum strategyEnum = StrategyEnum.valueOf(strategyCode);
            String className = strategyEnum.getClassName();
            Class<?> clazz = Class.forName(className);
            return (IStrategy) clazz.newInstance();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}
